# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=cilium-cli
pkgver=0.15.19
pkgrel=0
pkgdesc="CLI to install, manage and troubleshoot Kubernetes clusters running Cilium"
url="https://cilium.io/"
arch="all"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/cilium/cilium-cli/archive/refs/tags/v$pkgver.tar.gz"

export CGO_ENABLED=0
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v \
		-ldflags "-X github.com/cilium/cilium-cli/internal/cli/cmd.Version=v$pkgver" \
		./cmd/cilium

	for shell in bash fish zsh; do
		./cilium completion $shell > cilium.$shell
	done
}

check() {
	go test ./...
}

package() {
	install -Dm755 cilium -t "$pkgdir"/usr/bin/

	install -Dm644 cilium.bash \
		"$pkgdir"/usr/share/bash-completion/completions/cilium
	install -Dm644 cilium.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/cilium.fish
	install -Dm644 cilium.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_cilium
}

sha512sums="
62d333012c014a9500f23038af7908af6f16a70fea671d9b44c9557832f9f57103b7306838dc1f2c91500ab78e26fe190247eb34ed4e9e53ed4baf7d0390a540  cilium-cli-0.15.19.tar.gz
"
